﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using System.Xml;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using YArchitech.Revit;
using HYElectricCommon;
using Microsoft.Win32;

namespace HYRElectric.PowerSystem
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdSystemData : YJKCommandAuto
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			this.uiDoc = cmdData.Application.ActiveUIDocument;
			this.commandData = cmdData;
            Autodesk.Revit.DB.View activeView = this.uiDoc.Document.ActiveView;
			Selection selection = this.uiDoc.Selection;
			Result result;
			try
			{
				this.InitSharePara();
				this.GetAllPanelAndPowerValue();
				if (this.isGetPara != 0)
				{
					result = Autodesk.Revit.UI.Result.Failed;
				}
				else if (!this.WriteXml(this.allPowerAndPanel))
				{
					MessageBox.Show("数据写入文件失败！", "盈建科提示");
					result = Autodesk.Revit.UI.Result.Failed;
				}
				else
				{
					this.StartCAD();
					if (!string.IsNullOrEmpty(this.path))
					{
						Process.Start(this.path, "RevitDQ");
						result = Autodesk.Revit.UI.Result.Succeeded;
					}
					else
					{
						MessageBox.Show("未查找到HYDQ1.5版本软件的安装，请先安装！", "盈建科提示");
						result = Autodesk.Revit.UI.Result.Failed;
					}
				}
			}
			catch (Exception)
			{
				result = Autodesk.Revit.UI.Result.Failed;
			}
			return result;
		}

		private void StartCAD()
		{
			using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Hongye\\HYDQ\\1.5\\HYDQ-140", false))
			{
				if (registryKey != null)
				{
					this.path = registryKey.GetValue("Location") + "HyDq.exe";
				}
			}
		}

		private void InitSharePara()
		{
			CStandardManual.GetAllLayingMode(ref this.vecLayingMode);
			CStandardManual.GetAllPipeType(ref this.vecPipeType);
			CStandardManual.GetAllSwitchLocalName(ref this.vecLocalName);
			CStandardManual.GetAllSwitchType(ref this.vecSwitchType);
			CStandardManual.GetAllWireType(ref this.vecWireType);
		}

		private bool WriteXml(List<CSystemDataBlock> allPowerAndPanel)
		{
			bool result;
			try
			{
				if (allPowerAndPanel.Count > 0)
				{
					XmlDocument xmlDocument = new XmlDocument();
					XmlDeclaration newChild = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null);
					xmlDocument.AppendChild(newChild);
					XmlElement newChild2 = xmlDocument.CreateElement("Boot");
					xmlDocument.AppendChild(newChild2);
					XmlNode xmlNode = xmlDocument.SelectSingleNode("Boot");
					XmlElement xmlElement = xmlDocument.CreateElement("DataItems");
					foreach (CSystemDataBlock csystemDataBlock in allPowerAndPanel)
					{
						XmlElement xmlElement2 = xmlDocument.CreateElement("DataItem");
						xmlElement2.SetAttribute("GUID", csystemDataBlock.StrGUID);
						xmlElement2.SetAttribute("DataType", csystemDataBlock.NDataType.ToString());
						if (csystemDataBlock.NDataType == 0)
						{
							FamilyInstance familyInstance = csystemDataBlock.M_object as FamilyInstance;
							xmlElement2.SetAttribute("Prefix", familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_NAMING).AsInteger().ToString());
							xmlElement2.SetAttribute("Num", csystemDataBlock.StrNum);
						}
						else
						{
							FamilyInstance baseEquipment = (csystemDataBlock.M_object as ElectricalSystem).BaseEquipment;
							int num = baseEquipment.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_NAMING).AsInteger();
							string text = "";
							switch (num)
							{
							case 0:
								text = baseEquipment.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_PREFIX).AsString();
								text += baseEquipment.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_PREFIX_SEPARATOR).AsString();
								break;
							case 2:
								text = baseEquipment.get_Parameter(BuiltInParameter.RBS_ELEC_PANEL_NAME).AsString();
								text += baseEquipment.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_PREFIX_SEPARATOR).AsString();
								break;
							case 3:
								text = csystemDataBlock.StrPhase;
								break;
							}
							string value;
							try
							{
								value = csystemDataBlock.StrNum.Remove(0, text.Length);
							}
							catch (Exception)
							{
								value = csystemDataBlock.StrNum;
							}
							xmlElement2.SetAttribute("Prefix", text);
							xmlElement2.SetAttribute("Num", value);
						}
						xmlElement2.SetAttribute("LoadType", csystemDataBlock.StrLoadType);
						xmlElement2.SetAttribute("Phase", csystemDataBlock.StrPhase);
						xmlElement2.SetAttribute("Pe", csystemDataBlock.DPe.ToString());
						xmlElement2.SetAttribute("Ur", csystemDataBlock.DUr.ToString());
						xmlElement2.SetAttribute("Kx", csystemDataBlock.DKx.ToString());
						xmlElement2.SetAttribute("Cos", csystemDataBlock.DCos.ToString());
						xmlElement2.SetAttribute("Ic", csystemDataBlock.DIc.ToString());
						xmlElement2.SetAttribute("WireType", csystemDataBlock.StrWireType);
						xmlElement2.SetAttribute("WireNum", csystemDataBlock.NWireNum.ToString());
						xmlElement2.SetAttribute("Laying", csystemDataBlock.StrLaying);
						xmlElement2.SetAttribute("WireS", csystemDataBlock.DWireS.ToString());
						xmlElement2.SetAttribute("PipeType", csystemDataBlock.StrPipeType);
						xmlElement2.SetAttribute("PipeDia", csystemDataBlock.DPipeDia.ToString());
						string value2 = "";
						CStandardManual.GetSwitchNameByLocalName(csystemDataBlock.StrSwitchName, ref value2);
						xmlElement2.SetAttribute("SwitchName", value2);
						if (CStandardManual.IsSeparate(csystemDataBlock.StrSwitchType))
						{
							xmlElement2.SetAttribute("SwitchType", csystemDataBlock.StrSwitchType + "-");
						}
						else
						{
							xmlElement2.SetAttribute("SwitchType", csystemDataBlock.StrSwitchType);
						}
						xmlElement2.SetAttribute("SwitchSpec", csystemDataBlock.StrSwitchSpec);
						xmlElement2.SetAttribute("ParentGUID", csystemDataBlock.StrParentGUID);
						xmlElement.AppendChild(xmlElement2);
					}
					xmlNode.AppendChild(xmlElement);
					xmlDocument.Save(HYElectricCommon.AssistFunc.GetAppRootPath() + "\\Data\\SystemGraph.xml");
					result = true;
				}
				else
				{
					result = false;
				}
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private void GetAllPanelAndPowerValue()
		{
			ICollection<Element> collection = new FilteredElementCollector(this.uiDoc.ActiveView.Document).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_ElectricalEquipment).ToElements();
			if (collection.Count > 0)
			{
				this.AllPowerEquipment();
				foreach (Element element in collection)
				{
					List<ElementId> list = new List<ElementId>();
					bool flag = false;
					list.Clear();
					foreach (FindPowerAndPanel findPowerAndPanel in this.equSet)
					{
						if (findPowerAndPanel.PanelId == element.Id)
						{
							flag = true;
							if (!list.Contains(findPowerAndPanel.PowerId))
							{
								list.Add(findPowerAndPanel.PowerId);
							}
						}
					}
					if (this.powerList.Count > 0)
					{
						this.powerList.Clear();
					}
					if (list.Count > 0)
					{
						foreach (ElementId power in list)
						{
							try
							{
								this.GetDataOfPower(element, power);
							}
							catch (Exception)
							{
								MessageBox.Show("获取回路参数信息失败！", "盈建科提示");
								this.isGetPara++;
								return;
							}
						}
					}
					if (flag)
					{
						try
						{
							this.GetDataOfPanel(element);
						}
						catch (Exception)
						{
							MessageBox.Show("获取配电箱参数信息失败！", "盈建科提示");
							this.isGetPara++;
						}
					}
				}
			}
		}

		public void AllPowerEquipment()
		{
			this.equSet.Clear();
			foreach (Element element in new FilteredElementCollector(this.uiDoc.ActiveView.Document).OfClass(typeof(FamilyInstance)).ToElements())
			{
				FamilyInstance familyInstance = element as FamilyInstance;
				ElectricalSystemSet electricalSystems = familyInstance.MEPModel.ElectricalSystems;
				bool flag = false;
				try
				{
					ConnectorSetIterator connectorSetIterator = familyInstance.MEPModel.ConnectorManager.Connectors.ForwardIterator();
					while (connectorSetIterator.MoveNext())
					{
						if ((connectorSetIterator.Current as Connector).Domain == (Autodesk.Revit.DB.Domain)2)
						{
							flag = true;
							break;
						}
					}
				}
				catch (Exception)
				{
					continue;
				}
				if (flag && !string.IsNullOrEmpty(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_PANEL_PARAM).AsString()) && electricalSystems != null)
				{
					foreach (object obj in electricalSystems)
					{
						ElectricalSystem electricalSystem = (ElectricalSystem)obj;
						if (!this.equSet.Contains(new FindPowerAndPanel
						{
							PowerId = electricalSystem.Id,
							PanelId = electricalSystem.BaseEquipment.Id
						}))
						{
							this.equSet.Add(new FindPowerAndPanel
							{
								PowerId = electricalSystem.Id,
								PanelId = electricalSystem.BaseEquipment.Id
							});
						}
					}
				}
			}
		}

		private void GetDataOfPower(Element panelEle, ElementId power)
		{
			FamilyInstance familyInstance = panelEle as FamilyInstance;
			CSystemDataBlock csystemDataBlock = new CSystemDataBlock();
			Element elementById = this.uiDoc.ActiveView.Document.GetElementById(power);
			ElectricalSystem electricalSystem = elementById as ElectricalSystem;
			ElementSet elements = electricalSystem.Elements;
			csystemDataBlock.M_object = elementById;
			csystemDataBlock.NDataType = 1;
			csystemDataBlock.StrGUID = electricalSystem.Id.ToString();
			csystemDataBlock.StrNum = electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_CIRCUIT_NUMBER).AsString();
			csystemDataBlock.StrLoadType = electricalSystem.get_Parameter(BuiltInParameter.CIRCUIT_LOAD_CLASSIFICATION_PARAM).AsString();
			double num = electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEA).AsDouble();
			double num2 = electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEB).AsDouble();
			double num3 = electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEC).AsDouble();
			if (num != 0.0 && num2 == 0.0 && num3 == 0.0)
			{
				csystemDataBlock.StrPhase = "A";
			}
			else if (num2 != 0.0 && num == 0.0 && num3 == 0.0)
			{
				csystemDataBlock.StrPhase = "B";
			}
			else if (num3 != 0.0 && num2 == 0.0 && num == 0.0)
			{
				csystemDataBlock.StrPhase = "C";
			}
			else
			{
				csystemDataBlock.StrPhase = "3P";
			}
			try
			{
				double num4 = 0.0;
				foreach (object obj in elements)
				{
					FamilyInstance familyInstance2 = ((Element)obj) as FamilyInstance;
					double num5 = this.RevitToK(familyInstance2.Symbol.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD).AsDouble());
					if (num5 != 0.0)
					{
						num4 += num5;
					}
				}
				if (num4 <= 0.0)
				{
					csystemDataBlock.DPe = this.RevitToK(electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD).AsDouble());
				}
				else
				{
					csystemDataBlock.DPe = num4;
				}
			}
			catch (Exception)
			{
				csystemDataBlock.DPe = this.RevitToK(electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD).AsDouble());
			}
			csystemDataBlock.DUr = this.RevitToV(Convert.ToDouble(electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_VOLTAGE).AsDouble()));
			csystemDataBlock.DKx = Math.Round(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_PANEL_TOTAL_DEMAND_FACTOR_PARAM).AsDouble(), 2);
			csystemDataBlock.DCos = electricalSystem.get_Parameter(BuiltInParameter.RBS_ELEC_POWER_FACTOR).AsDouble();
			if (csystemDataBlock.StrPhase != "3P")
			{
				csystemDataBlock.DIc = Math.Round(csystemDataBlock.DPe * csystemDataBlock.DKx / (csystemDataBlock.DUr * csystemDataBlock.DCos), 2);
			}
			else
			{
				csystemDataBlock.DIc = Math.Round(csystemDataBlock.DPe * csystemDataBlock.DKx / (Math.Sqrt(3.0) * csystemDataBlock.DUr * csystemDataBlock.DCos), 2);
			}
			try
			{
				csystemDataBlock.StrWireType = electricalSystem.GetParameter("导线类别").AsString();
				if (string.IsNullOrEmpty(csystemDataBlock.StrWireType))
				{
					csystemDataBlock.StrWireType = this.vecWireType[0];
				}
			}
			catch (Exception)
			{
				ElectricSystemCommand.AddShardParameters(this.uiDoc.Document, familyInstance, electricalSystem);
				csystemDataBlock.StrWireType = electricalSystem.GetParameter("导线类别").AsString();
				if (string.IsNullOrEmpty(csystemDataBlock.StrWireType))
				{
					csystemDataBlock.StrWireType = this.vecWireType[0];
				}
			}
			if (csystemDataBlock.StrPhase != "3P")
			{
				csystemDataBlock.NWireNum = 2;
			}
			else
			{
				csystemDataBlock.NWireNum = 4;
			}
			csystemDataBlock.StrLaying = electricalSystem.GetParameter("敷设方式").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrLaying))
			{
				csystemDataBlock.StrLaying = this.vecLayingMode[0];
			}
			double dwireS = 0.0;
			double num6 = 0.0;
			CStandardManual.GetWireSAndA(csystemDataBlock.StrWireType, csystemDataBlock.NWireNum, csystemDataBlock.DIc, ref dwireS, ref num6);
			csystemDataBlock.DWireS = dwireS;
			csystemDataBlock.StrPipeType = electricalSystem.GetParameter("穿管类型").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrPipeType))
			{
				csystemDataBlock.StrPipeType = this.vecPipeType[0];
			}
			double dpipeDia = 0.0;
			CStandardManual.GetPipeDia(csystemDataBlock.StrWireType, csystemDataBlock.NWireNum, csystemDataBlock.DWireS, csystemDataBlock.StrPipeType, ref dpipeDia);
			csystemDataBlock.DPipeDia = dpipeDia;
			csystemDataBlock.StrSwitchName = electricalSystem.GetParameter("开关名称").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrSwitchName))
			{
				csystemDataBlock.StrSwitchName = this.vecLocalName[0];
			}
			csystemDataBlock.StrSwitchType = electricalSystem.GetParameter("开关型号").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrSwitchType))
			{
				csystemDataBlock.StrSwitchType = this.vecSwitchType[0];
			}
			double num7 = 0.0;
			CStandardManual.GetSwitchSpec(csystemDataBlock.StrSwitchType, csystemDataBlock.DIc, ref num7);
			csystemDataBlock.StrSwitchSpec = num7.ToString();
			csystemDataBlock.StrParentGUID = familyInstance.Id.ToString();
			this.powerList.Add(csystemDataBlock);
			bool flag = false;
			using (List<CSystemDataBlock>.Enumerator enumerator2 = this.allPowerAndPanel.GetEnumerator())
			{
				while (enumerator2.MoveNext())
				{
					if (enumerator2.Current.StrGUID == csystemDataBlock.StrGUID)
					{
						flag = true;
					}
				}
			}
			if (!flag)
			{
				this.allPowerAndPanel.Add(csystemDataBlock);
			}
		}

		private double RevitToV(double revit)
		{
			return Math.Round(revit / 10.7639104167079, MidpointRounding.AwayFromZero);
		}

		private double RevitToK(double revit)
		{
			return Math.Round(revit / 10.7639104167079, MidpointRounding.AwayFromZero);
		}

		private void GetDataOfPanel(Element element)
		{
			FamilyInstance familyInstance = element as FamilyInstance;
			CSystemDataBlock csystemDataBlock = new CSystemDataBlock();
			csystemDataBlock.M_object = element;
			csystemDataBlock.NDataType = 0;
			csystemDataBlock.StrGUID = familyInstance.Id.ToString();
			csystemDataBlock.StrNum = familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_PANEL_NAME).AsString();
			List<string> list = new List<string>();
			if (this.powerList.Count > 0)
			{
				list.Add(this.powerList[0].StrLoadType);
			}
			bool flag = true;
			if (list.Count > 0)
			{
				for (int i = 1; i < this.powerList.Count; i++)
				{
					if (list[0] != this.powerList[i].StrLoadType)
					{
						flag = false;
					}
				}
				if (flag)
				{
					csystemDataBlock.StrLoadType = list[0];
				}
				else
				{
					csystemDataBlock.StrLoadType = "*";
				}
			}
			double num = familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEA).AsDouble();
			double num2 = familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEB).AsDouble();
			double num3 = familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEC).AsDouble();
			if (num != 0.0 && num2 == 0.0 && num3 == 0.0)
			{
				csystemDataBlock.StrPhase = "A";
			}
			else if (num2 != 0.0 && num == 0.0 && num3 == 0.0)
			{
				csystemDataBlock.StrPhase = "B";
			}
			else if (num3 != 0.0 && num2 == 0.0 && num == 0.0)
			{
				csystemDataBlock.StrPhase = "C";
			}
			else
			{
				csystemDataBlock.StrPhase = "3P";
			}
			if (csystemDataBlock.StrPhase == "A")
			{
				csystemDataBlock.DPe = this.RevitToK(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEA).AsDouble());
			}
			else if (csystemDataBlock.StrPhase == "B")
			{
				csystemDataBlock.DPe = this.RevitToK(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEB).AsDouble());
			}
			else if (csystemDataBlock.StrPhase == "C")
			{
				csystemDataBlock.DPe = this.RevitToK(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEC).AsDouble());
			}
			else
			{
                csystemDataBlock.DPe = this.RevitToK(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEA).AsDouble()) + this.RevitToK(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEB).AsDouble()) + this.RevitToK(familyInstance.get_Parameter(BuiltInParameter.RBS_ELEC_APPARENT_LOAD_PHASEC).AsDouble());
			}
			FamilyInstance familyInstance2 = familyInstance;
			double revit;
			try
			{
				revit = Convert.ToDouble(familyInstance2.Symbol.GetParameter("配电盘电压").AsDouble());
			}
			catch (Exception)
			{
				revit = Convert.ToDouble(familyInstance2.Symbol.GetParameter("配电箱电压").AsDouble());
			}
			csystemDataBlock.DUr = this.RevitToV(revit);
			csystemDataBlock.DKx = Math.Round(familyInstance.GetParameter(BuiltInParameter.RBS_ELEC_PANEL_TOTAL_DEMAND_FACTOR_PARAM).AsDouble(), 2);
			double num4 = 0.0;
			if (this.powerList.Count > 0)
			{
				for (int j = 0; j < this.powerList.Count; j++)
				{
					double dcos = this.powerList[j].DCos;
					num4 += this.powerList[j].DCos;
				}
			}
			csystemDataBlock.DCos = num4 / (double)this.powerList.Count;
			if (csystemDataBlock.StrPhase != "3P")
			{
				csystemDataBlock.DIc = Math.Round(csystemDataBlock.DPe * csystemDataBlock.DKx / (csystemDataBlock.DUr * csystemDataBlock.DCos), 2);
			}
			else
			{
				csystemDataBlock.DIc = Math.Round(csystemDataBlock.DPe * csystemDataBlock.DKx / (Math.Sqrt(3.0) * csystemDataBlock.DUr * csystemDataBlock.DCos), 2);
			}
			csystemDataBlock.StrWireType = familyInstance.GetParameter("导线类别").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrWireType))
			{
				csystemDataBlock.StrWireType = this.vecWireType[0];
			}
			if (csystemDataBlock.StrPhase != "3P")
			{
				csystemDataBlock.NWireNum = 2;
			}
			else
			{
				csystemDataBlock.NWireNum = 4;
			}
			double dwireS = 0.0;
			double num5 = 0.0;
			CStandardManual.GetWireSAndA(csystemDataBlock.StrWireType, csystemDataBlock.NWireNum, csystemDataBlock.DIc, ref dwireS, ref num5);
			csystemDataBlock.DWireS = dwireS;
			csystemDataBlock.StrPipeType = familyInstance.GetParameter("穿管类型").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrPipeType))
			{
				csystemDataBlock.StrPipeType = this.vecPipeType[0];
			}
			double dpipeDia = 0.0;
			CStandardManual.GetPipeDia(csystemDataBlock.StrWireType, csystemDataBlock.NWireNum, csystemDataBlock.DWireS, csystemDataBlock.StrPipeType, ref dpipeDia);
			csystemDataBlock.DPipeDia = dpipeDia;
			csystemDataBlock.StrLaying = familyInstance.GetParameter("敷设方式").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrLaying))
			{
				csystemDataBlock.StrLaying = this.vecLayingMode[0];
			}
			csystemDataBlock.StrSwitchName = familyInstance.GetParameter("开关名称").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrSwitchName))
			{
				csystemDataBlock.StrSwitchName = this.vecLocalName[0];
			}
			csystemDataBlock.StrSwitchType = familyInstance.GetParameter("开关型号").AsString();
			if (string.IsNullOrEmpty(csystemDataBlock.StrSwitchType))
			{
				csystemDataBlock.StrSwitchType = this.vecSwitchType[0];
			}
			double num6 = 0.0;
			CStandardManual.GetSwitchSpec(csystemDataBlock.StrSwitchType, csystemDataBlock.DIc, ref num6);
			csystemDataBlock.StrSwitchSpec = num6.ToString();
			string strParentGUID = "";
			ElectricalSystemSet electricalSystems = familyInstance.MEPModel.ElectricalSystems;
			if (electricalSystems != null)
			{
				foreach (object obj in electricalSystems)
				{
					strParentGUID = ((ElectricalSystem)obj).Id.ToString();
				}
			}
			csystemDataBlock.StrParentGUID = strParentGUID;
			bool flag2 = false;
			using (List<CSystemDataBlock>.Enumerator enumerator2 = this.allPowerAndPanel.GetEnumerator())
			{
				while (enumerator2.MoveNext())
				{
					if (enumerator2.Current.StrGUID == csystemDataBlock.StrGUID)
					{
						flag2 = true;
					}
				}
			}
			if (!flag2)
			{
				this.allPowerAndPanel.Add(csystemDataBlock);
			}
		}

		private UIDocument uiDoc;

		private string path = "";

		private List<CSystemDataBlock> allPowerAndPanel = new List<CSystemDataBlock>();

		private ExternalCommandData commandData;

		private List<string> vecPipeType = new List<string>();

		private List<string> vecLayingMode = new List<string>();

		private List<string> vecLocalName = new List<string>();

		private List<string> vecSwitchType = new List<string>();

		private List<string> vecWireType = new List<string>();

		private int isGetPara;

		private List<FindPowerAndPanel> equSet = new List<FindPowerAndPanel>();

		private List<CSystemDataBlock> powerList = new List<CSystemDataBlock>();

		private List<CSystemDataBlock> panelList = new List<CSystemDataBlock>();
	}
}
